package com.boxfishedu.foreignkey.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lzx on 16/3/9.
 */
@ControllerAdvice
public class ExceptionController {


    @ExceptionHandler(value = ValidationException.class)
    @ResponseBody
    public Object exceptionHandle(ValidationException v) {
        Map<String, Object> map = new HashMap();
        map.put("code", 1);
        map.put("message", v.getMessage());
        return map;
    }
}
